package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.AppealPageQueryDTO;
import com.sky.entity.Appeal;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AppealMapper {

    @Select("select * from appeal where id = #{id}")
    Appeal getById(Long id);

    Page<Appeal> pageQuery(AppealPageQueryDTO pageQuery);

    Page<Appeal> mypageQuery(AppealPageQueryDTO pageQuery);

    @Insert("insert into appeal (id,violation_id,type,violation_type,image_path,location,status,create_time,create_user,file,car_id,reason,begin_time) values (#{id},#{violationId},#{type},#{violationType},#{imagePath},#{location},#{status},#{createTime},#{createUser},#{file},#{carId},#{reason},#{beginTime})")
    @AutoFill(value = OperationType.INSERT)
    public void insert(Appeal appeal);

    @AutoFill(value = OperationType.UPDATE)
    void update(Appeal appeal);

    Double getMyWaitingAppeal(Long currentId);
}
